package svc

import (
	"api/internal/config"
	"api/internal/middleware"
	"book_srv/booksrvclient"
	"github.com/zeromicro/go-zero/rest"
	"github.com/zeromicro/go-zero/zrpc"
	"user_srv/usersrvclient"
)

type ServiceContext struct {
	Config         config.Config
	AuthMiddleware rest.Middleware
	BookSrv        booksrvclient.BookSrv
	UserSrv        usersrvclient.UserSrv
}

func NewServiceContext(c config.Config) *ServiceContext {
	return &ServiceContext{
		Config:         c,
		AuthMiddleware: middleware.NewAuthMiddleware().Handle,
		BookSrv:        booksrvclient.NewBookSrv(zrpc.MustNewClient(c.BookSrv)),
		UserSrv:        usersrvclient.NewUserSrv(zrpc.MustNewClient(c.UserSrv)),
	}
}
